﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 信息类别逻辑类
    /// </summary>
    public class DocCls
    {
        /// <summary>
        /// 信息类类别数据类
        /// </summary>
        private readonly DAL.DocCls docClsDAL= new DAL.DocCls();
        /// <summary>
        /// 构造函数
        /// </summary>
		public DocCls()
		{}
        
        
        /// <summary>
        /// 得到一个对象
        /// <creator>wangl</creator>
        /// <date>2013-07-23</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns></returns>
        public Model.DocCls GetModel(string entityNo, string docClsCd)
        {
            return docClsDAL.GetModel(entityNo, docClsCd);
        }
        
        /// <summary>
        /// 特定栏目是否有特定的权限
        /// <creator>wangl</creator>
        /// <date>2013-08-06</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="empNo">员工编号</param>
        /// <param name="deptNo">部门编号</param>
        /// <param name="authority">权限</param>
        /// <param name="docClsNo">信息类别编号</param>
        /// <returns></returns>
        public bool ExistsAuthorityDocClsNo(string entityNo, string empNo, string deptNo, string authority, string docClsNo)
        {
            return docClsDAL.ExistsAuthorityDocClsNo(entityNo, empNo, deptNo, authority, docClsNo);
        }
        /// <summary>
        /// 根据编号，获取其父类编号和其组成的路径 01/02/03
        /// <creator>wangl</creator>
        /// <date>2013-08-13</date> 
        /// </summary>
        /// <param name="docClsCd">信息类别编号</param>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public string GetDocClsCdS(string docClsCd, string entityNo)
        {
            return docClsDAL.GetDocClsCdS(docClsCd, entityNo);
        }
        /// <summary>
        /// 获取信息类别名称路径名
        /// <creator>wangl</creator>
        /// <date>2013-08-14</date> 
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docClsCd">信息类别编号</param>
        /// <returns>名称路径名</returns>
        public string GetDocClsPathNames(string entityNo, string docClsCd)
        {
            return docClsDAL.GetDocClsPathNames(entityNo, docClsCd);
        }
         /// <summary>
        /// 获取所有的有效的子栏目 null 为全部
        /// <creator>wangl</creator>
        /// <date>2013-09-09</date>
        /// </summary>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public DataSet GetAllSubDocCls(string docClsCd, string entityNo)
        {
            return docClsDAL.GetAllSubDocCls(docClsCd, entityNo);
        }
         /// <summary>
        /// 获取下一级的有效的子栏目
        /// <creator>wangl</creator>
        /// <date>2014-02-27</date>
        /// </summary>
        /// <param name="FDocClsCd"></param>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public DataSet GetSubDocCls(string docClsCd, string entityNo)
        {
            return docClsDAL.GetSubDocCls(docClsCd, entityNo);
        }
        /// <summary>
        /// 获取专题专栏(已启用)
        /// <creator>wangl</creator>
        /// <date>2013-10-30</date>
        /// </summary>
        /// <param name="preDocClsID"></param>
        /// <param name="entityNo"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public Dictionary<string, string> GetIdAndLogUrl(string preDocClsID, string entityNo, int top = 0)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            DataSet ds = docClsDAL.GetIdAndLogUrl(preDocClsID, entityNo, top);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                dic.Add(row["FDocClsCd"].ToString(), row["FLogoNewFileName"].ToString());
            }

            return dic;
        }

        /// <summary>
        /// 获取专题专栏(包含启用未启用)
        /// <creator>wangl</creator>
        /// <date>2013-10-30</date>
        /// </summary>
        /// <param name="preDocClsID"></param>
        /// <param name="entityNo"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public Dictionary<string, string> GetIdAndLogUrlAll(string preDocClsID, string entityNo, int top = 0)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            DataSet ds = docClsDAL.GetIdAndLogUrlAll(preDocClsID, entityNo, top);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                dic.Add(row["FDocClsCd"].ToString(), row["FLogoNewFileName"].ToString());
            }

            return dic;
        }
        public List<ElingOA6_DSJCJ.Model.DocCls> GetModelList(string strWhere)
        {
            DataSet ds = docClsDAL.GetList(strWhere);
            List<ElingOA6_DSJCJ.Model.DocCls> l= new List<ElingOA6_DSJCJ.Model.DocCls>();
            foreach (DataRow r in ds.Tables[0].Rows)
            {

             ElingOA6_DSJCJ.Model.DocCls m=   docClsDAL.DataRowToModel(r);
             l.Add(m);
            }
            return l;
        }

        /// <summary>
        /// 获取某目录的一级下级目录的部分字段List
        /// </summary>
        /// <param name="preDocClsCd"></param>
        /// <param name="entityNO"></param>
        /// <returns></returns>
        public List<Model.DocCls> GetSubDocClsOneList(string preDocClsCd, string entityNO)
        {
            List<Model.DocCls> list = new List<Model.DocCls>();
            DataSet ds = docClsDAL.GetSubDocClsOne(preDocClsCd, entityNO);
            Model.DocCls model;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                model = new Model.DocCls();
                model.FDocClsCd = row["FDocClsCd"].ToString();
                model.FDocClsName = row["FDocClsName"].ToString();
                model.FPreDocClsCd = row["FPreDocClsCd"].ToString();
                list.Add(model);
            }

            return list;
        }


        /// <summary>
        /// 根据用户权限获取树目录
        /// <creator>sunlj</creator>
        /// <date>2014-05-24</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="empNo">员工编号</param>
        /// <param name="deptNo">部门编号</param>
        /// <param name="authority">权限</param>
        /// <returns></returns>
        //public DataTable GetListByAuthority(string entityNo, string empNo, string deptNo, string authority)
        //{
        //    return docClsDAL.GetListByAuthority(entityNo, empNo, deptNo, authority).Tables[0];

        //}
        public DataTable GetListByAuthority(string entityNo, string empNo, string deptNo, string authority, decimal docId, string docClsCd)
        {
            return docClsDAL.GetListByAuthority(entityNo, empNo, deptNo, authority, docId, docClsCd).Tables[0];
        }
        /// <summary>
        /// 获取分局的信息类别
        /// <creator>sunlj</creator>
        /// <date>2013-09-07</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="deptNo">部门编号</param>
        /// <returns></returns>
        public DataTable GetLZZCDocCls(string entityNo, string clsCd)
        {
            return docClsDAL.GetLZZCDocCls(entityNo, clsCd).Tables[0];
        }
    }
}
